package com.example.a22310.myapplication.Beans;

import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.CourseDetail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class ClubCourse {

    /**
     * code : 200
     * clubcourselist : [{"course_id":"2","course_name":"1","course_time":"2017-09-15 00:00:00","course_place":"1","course_free":"1","course_intro":"","course_instru":"1","course_num":"1","course_picture":"59b0bb2c15bc9.png","club_id":"1"},{"course_id":"3","course_name":"跳水","course_time":"2017-10-23 13:00:12","course_place":"dalain ","course_free":"11","course_intro":"1111","course_instru":"1111111111","course_num":"1111111111","course_picture":"1.jpg","club_id":"0"}]
     */

    private int code;
    private List<ClubcourselistBean> clubcourselist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<ClubcourselistBean> getClubcourselist() {
        return clubcourselist;
    }

    public void setClubcourselist(List<ClubcourselistBean> clubcourselist) {
        this.clubcourselist = clubcourselist;
    }

    public static class ClubcourselistBean extends BaseObservable implements Serializable {
        /**
         * course_id : 2
         * course_name : 1
         * course_time : 2017-09-15 00:00:00
         * course_place : 1
         * course_free : 1
         * course_intro :
         * course_instru : 1
         * course_num : 1
         * course_picture : 59b0bb2c15bc9.png
         * club_id : 1
         */

        private String course_id;
        private String course_name;
        private String course_time;
        private String course_place;
        private String course_free;
        private String course_intro;
        private String course_instru;
        private String course_num;
        private String course_picture;
        private String club_id;




        public ClubcourselistBean(String course_id,  String course_name, String course_time, String course_place,String course_free,
                                  String course_intro,String course_instru,String course_num,String course_picture,String club_id) {
            this.course_id = course_id;
            this.course_name = course_name;
            this.course_time=course_time;
            this.course_place =course_place;
            this.course_free = course_free;
            this.course_intro = course_intro;
            this.course_instru=course_instru;
            this.course_num=course_num;
            this.course_picture=course_picture;
            this.club_id=club_id;
        }

        @BindingAdapter("course_picture")
        public static void loadInternetImage(ImageView iv, String course_picture) {
            course_picture = IMG_URL+course_picture;
            Picasso.with(iv.getContext()).load(course_picture).into(iv);
        }

        @Override
        public String toString() {
            return "ClublistBean{" +
                    "course_id='" + course_id + '\'' +
                    ", course_name='" + course_name + '\'' +
                    ", course_time='" + course_time + '\'' +
                    "course_place='" + course_place + '\'' +
                    ", course_free='" + course_free + '\'' +
                    ", course_intro='" + course_intro + '\'' +
                    "course_instru='" + course_instru + '\'' +
                    ", course_num='" + course_num + '\'' +
                    ", course_picture='" + course_picture + '\'' +
                    "club_id='" + club_id + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),CourseDetail.class);
            //往详情传递数据
            ClubCourse.ClubcourselistBean clubcourselistBean = new ClubCourse.ClubcourselistBean();
            clubcourselistBean.setClub_id(getClub_id());
            clubcourselistBean.setCourse_free(getCourse_free());
            clubcourselistBean.setCourse_id(getCourse_id());
            clubcourselistBean.setCourse_instru(getCourse_instru());
            clubcourselistBean.setCourse_name(getCourse_name());
            clubcourselistBean.setCourse_intro(getCourse_intro());
            clubcourselistBean.setCourse_num(getCourse_num());
            clubcourselistBean.setCourse_place(getCourse_place());
            clubcourselistBean.setCourse_picture(getCourse_picture());
            clubcourselistBean.setCourse_time(getCourse_time());
            intent.putExtra("clubcourse",clubcourselistBean);
            view.getContext().startActivity(intent);
        }

        @Bindable





        public String getCourse_id() {
            return course_id;
        }

        public void setCourse_id(String course_id) {
            this.course_id = course_id;
        }

        public String getCourse_name() {
            return course_name;
        }

        public void setCourse_name(String course_name) {
            this.course_name = course_name;
        }

        public String getCourse_time() {
            return course_time;
        }

        public void setCourse_time(String course_time) {
            this.course_time = course_time;
        }

        public String getCourse_place() {
            return course_place;
        }

        public void setCourse_place(String course_place) {
            this.course_place = course_place;
        }

        public String getCourse_free() {
            return "￥"+course_free;
        }

        public void setCourse_free(String course_free) {
            this.course_free = course_free;
        }

        public String getCourse_intro() {
            return course_intro;
        }

        public void setCourse_intro(String course_intro) {
            this.course_intro = course_intro;
        }

        public String getCourse_instru() {
            return course_instru;
        }

        public void setCourse_instru(String course_instru) {
            this.course_instru = course_instru;
        }

        public String getCourse_num() {
            return course_num;
        }

        public void setCourse_num(String course_num) {
            this.course_num = course_num;
        }

        public String getCourse_picture() {
            return IMG_URL+course_picture;
        }

        public void setCourse_picture(String course_picture) {
            this.course_picture = course_picture;
        }

        public String getClub_id() {
            return club_id;
        }

        public void setClub_id(String club_id) {
            this.club_id = club_id;
        }
    }
}
